// pages/goodslist/goodslist.js
import {search} from '../../utils/http'
Page({
    data: {
        currentIndexNav: 0,

        goods: [],
        value: '',
        good: [],
        show: true
    },

    onLoad: function (options) {
        console.log(options.val)
        if (options.goods == null) {
            let goods = JSON.stringify(options.goods)
            // console.log(goods)
        } else {
            let goods = JSON.parse(options.goods)
            // console.log(goods)
            this.setData({ goods: goods,value:options.val})
            this.searchHandle()
        }
        wx.setNavigationBarTitle({
            title: '商品列表'
        })
    },
    btn(e) {
        if (this.data.show == true) {
            this.setData({ show: false })
        } else {
            this.setData({ show: true })
        }

    },
    search(e) {
        console.log(e.detail.value)
        this.setData({ value: e.detail.value })
    },
    // 搜索
    searchHandle: function () {
      
        let val = this.data.value
        let token=wx.getStorageSync('token')
        console.log(val,token)
        search(val,token).then(res=>{
            console.log(res.data)
            this.setData({good:res.data})
        
        })
    
       
    }
})